﻿CREATE TABLE [dbo].[Tb_Gastos] (
    [Sysid]            INT           IDENTITY (1, 1) NOT NULL,
    [SysRendicion]     INT           NULL,
    [SysTipoGasto]     INT           NULL,
    [SysSubGasto]      INT           NULL,
    [SysTipoModoDoc]   INT           NULL,
    [SysTipoDocumento] INT           NULL,
    [NroDocumento]     VARCHAR (30)  NULL,
    [FechaDocumento]   DATETIME      NULL,
    [RutProveedor]     VARCHAR (15)  NULL,
    [NombreProveedor]     VARCHAR(100)           NULL,
    [Descripcion]      VARCHAR (350) NULL,
    [NroFolio]         INT           NULL,
    [MontoNeto]        INT           NULL,
    [IVA]              INT           NULL,
    [Retencion]        INT           NULL,
    [TotalPagado]      INT           NULL,
    [SysUpload]        INT           NULL,
    [SysUsuario]       INT           NULL,
    [FechaCreacion]    DATETIME      NULL,
    [Eliminado]        BIT           NULL,
    [Rechazado]        BIT           NULL,
    [ObservacionesSupervisor] VARCHAR(MAX) NULL, 
    [ObservacionesGerente] VARCHAR(MAX) NULL, 
    [MontoExento] INT NULL, 
    [TipoDocumentoGenerico] INT NULL, 
    CONSTRAINT [PK_Tb_Gastos] PRIMARY KEY CLUSTERED ([Sysid] ASC),
    CONSTRAINT [FK_Tb_Gastos_TB_Rendiciones] FOREIGN KEY ([SysRendicion]) REFERENCES [dbo].[TB_Rendiciones] ([Sysid]),
    CONSTRAINT [FK_Tb_Gastos_TB_TipoDocumento] FOREIGN KEY ([SysTipoDocumento]) REFERENCES [dbo].[TB_TipoDocumento] ([Sysid]),
    CONSTRAINT [FK_Tb_Gastos_TB_TipoGasto] FOREIGN KEY ([SysTipoGasto]) REFERENCES [dbo].[TB_TipoGasto] ([Sysid]),
    CONSTRAINT [FK_Tb_Gastos_TB_TipoGasto1] FOREIGN KEY ([SysSubGasto]) REFERENCES [dbo].[TB_TipoGasto] ([Sysid]),
    CONSTRAINT [FK_Tb_Gastos_TB_Upload] FOREIGN KEY ([SysUpload]) REFERENCES [dbo].[TB_Upload] ([Sysid]),
    CONSTRAINT [FK_Tb_Gastos_TB_Usuario] FOREIGN KEY ([SysUsuario]) REFERENCES [dbo].[TB_Usuario] ([Sysid])
);

